package demo;

class OuterClass {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;

    /**
     * 实例内部类：定义在类的内部  方法的外部！！
     * 1. 这个实例内部类 到底怎么使用？
     * 2. 如何访问和外部类一样的成员属性？
     */
    class InnerClass {
        public int data1 = 100;
        public int data4 = 4;
        private int data5 = 5;
        public static int data6 = 6;

        public void test() {
            /*OuterClass outerClass = new OuterClass();
            System.out.println(outerClass.data1);*/
            System.out.println("InnerClass::test()");
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("==========");
            System.out.println(data1);
            System.out.println(this.data1);
            System.out.println("外部类的this： "+OuterClass.this.data1);
            System.out.println(data2);
            System.out.println(data3);
        }
    }

    public void testA(){
        System.out.println("OuterClass::testA()");

        InnerClass innerClass = new InnerClass();
        System.out.println(innerClass.data1);
        System.out.println(innerClass.data4);
    }

}
public class Test {

    public class INN {

    }
    public static void main(String[] args) {
        OuterClass out = new OuterClass();
        out.testA();
        System.out.println(out.data1);


        new OuterClass().testA();
        System.out.println(new OuterClass().data1);


    }
    public static void main2(String[] args) {
        OuterClass.InnerClass innerClass =
                new OuterClass().new InnerClass();
        innerClass.test();
    }
    public static void main1(String[] args) {
        OuterClass out = new OuterClass();
        //System.out.println(out.data1);
        OuterClass.InnerClass innerClass =
                out.new InnerClass();
        innerClass.test();
        //InnerClass innerClass = new InnerClass();
    }
}